package com.bingxue.edu.management.shop.model.req;

import com.bingxue.edu.common.enums.ClassCategoryEnum;
import com.bingxue.edu.common.enums.CommonStatusEnum;
import com.bingxue.edu.common.enums.CouponValidTypeEnum;
import com.bingxue.edu.common.enums.DiscountTypeEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import java.time.LocalDateTime;
import java.util.List;

import static com.bingxue.edu.common.constant.DateConstants.FORMAT_TIME_YMD_HMS;

/**
 * 创建或修改优惠卷模板信息
 *
 * @author zq
 * @since 2024/08/19 00:02
 */
@Data
@Schema(description = "创建或修改优惠卷模板信息")
public class CouponTemplateReq {

    @Schema(description = "名称")
    @NotBlank(message = "名称不能为空")
    @Length(max = 32, message = "名称长度不能超过 {max} 个字符")
    private String name;

    @Schema(description = "图片")
    @Length(max = 255, message = "图片长度不能超过 {max} 个字符")
    private String image;

    @Schema(description = "发放数量")
    @NotNull(message = "发放数量不能为空")
    private Integer distributedCount;

    @Schema(description = "折扣类型")
    @NotNull(message = "折扣类型不能为空")
    private DiscountTypeEnum discountType;

    @Schema(description = "优惠金额")
    @NotNull(message = "优惠金额不能为空")
    private Double discountAmount;

    @Schema(description = "最大优惠金额")
    @NotNull(message = "最大优惠金额不能为空")
    private Double maxDiscountAmount;

    @Schema(description = "使用门槛金额")
    @NotNull(message = "使用门槛金额不能为空")
    private Double thresholdAmount;

    @Schema(description = "限制班级")
    private String singleClassIdLimit;

    @Schema(description = "限制班型")
    private List<ClassCategoryEnum> classCategoryLimit;

    @Schema(description = "限制科目")
    private List<String> classSubjectLimit;

    @Schema(description = "限制年级")
    private List<String> classGradeLimit;

    @Schema(description = "限制学期")
    private List<String> classTermLimit;

    @Schema(description = "限制学年")
    private List<String> classYearLimit;

    @Schema(description = "是否允许叠加使用")
    @NotNull(message = "是否允许叠加使用不能为空")
    private Boolean stackingUseEnabled;

    @Schema(description = "每人限领数量（0不限制）")
    @NotNull(message = "每人限领数量不能为空")
    private Integer receiveLimitCount;

    @Schema(description = "有效期类型")
    @NotNull(message = "有效期类型不能为空")
    private CouponValidTypeEnum validType;

    @Schema(description = "有效期起始时间")
    @JsonFormat(pattern = FORMAT_TIME_YMD_HMS)
    private LocalDateTime startValidTime;

    @Schema(description = "有效期结束时间")
    @JsonFormat(pattern = FORMAT_TIME_YMD_HMS)
    private LocalDateTime endValidTime;

    @Schema(description = "有效期天数")
    private Integer validDays;

    @Schema(description = "状态")
    @NotNull(message = "状态不能为空")
    private CommonStatusEnum status;

    @Schema(description = "描述")
    @Length(max = 255, message = "描述长度不能超过 {max} 个字符")
    private String description;
}
